<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <script type="text/javascript">
      let p1 = new Promise((resolve, reject) => {
        resolve('成功了')
      })

      let p2 = new Promise((resolve, reject) => {
        reject('success')
      })

      // let p3 = Promse.reject('失败')
      // 直接调用
      Promise.all([p1, p2]).then((result) => {
        console.log(result) //['成功了', 'success']
      }).catch((error) => {
        console.log(error)
        console.log('shibai')
      })




      // 通过函数 封装加一层

      function add() {
        return Promise.all([p1, p2]).then((result) => {
          console.log(result) //['成功了', 'success']
          return [{
            a: 1
          }]
        })
      }
      let app = add().then((result) => {
        console.log(result)
      }).catch((error) => {
        console.log('error') // 失败了，打出 '失败'

      })
    </script>
  </body>
</html>
